package _02_linked_list.exerc.reverse;

import _02_linked_list.exerc.ListNode;

/**
 * @author: mornd
 * @dateTime: 2023/6/2 - 16:16
 * 用于反转链表的方式二
 */
public class MyLinkedList {
    ListNode head;

    public MyLinkedList() {
    }

    public MyLinkedList(ListNode node) {
        this.head = node;
    }

    // 添加头节点
    void addFirst(ListNode node) {
        node.next = head;
        head = node;
    }

    // 删除头节点
    ListNode removeFirst() {
        ListNode h = head;
        if(h == null) {
            return null;
        }
        head = h.next;
        return h;
    }
}
